<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div style="width: 200px;height: 200px;background: red;"></div>
</body>
<script>
    var div = document.getElementsByTagName('div')[0];



    // div.onclick = function(){
    //     console.log("aaaa");
    // }


    // div.addEventListener('click',function(){
    //     console.log("bbbbb");
    // },false)

    //IE浏览器才能使用 （谷歌浏览器不行）
    div.attachEvent('onclick',function(){
        console.log("ccccc");
    })
</script>
</html>